import { connect } from 'react-redux'

function Counter(props) {
  const increment = () => {
    props.dispatch({ type: 'INCREMENT' })
  }

  const decrement = () => {
    props.dispatch({ type: 'DECREMENT' })
  }

  return (
    <div>
      <button onClick={increment}>+1</button>
      <button onClick={decrement}>-1</button>
      <span>总数: {props.counter}</span>
    </div>
  )
}

export default connect(state => ({ counter: state.counter }))(Counter)